package com.lan.viewObject;

import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors
public class SysResult {

    /**
     * 状态 (SysResultStatusEnum)
     * */
    private Integer status;

    /**
     * 消息
     * */
    private String msg;

    /**
     * 数据
     * */
    private Object data;

    /**
     * 总数
     * */
    private Integer total;

    public SysResult(Integer status, String msg, Object data, Integer total) {
        this.status = status;
        this.msg = msg;
        this.data = data;
        this.total = total;
    }

    /**
     * 业务执行失败默认返回.
     * */
    public static SysResult fail(){
        return new SysResult(40001,"业务执行失败",null,null);
    }

    public static SysResult fail(String msg){
        return new SysResult(40000,msg,null,null);
    }

    /**
     * 业务执行成功默认返回.
     * */
    public static SysResult success(){
        return new SysResult(200,"业务执行成功",null,null);
    }

    /**
     * 业务执行成功---data.
     * */
    public static SysResult success(Object o){
        return new SysResult(200,"业务执行成功",o,null);
    }
}
